define(function(require, exports){
	var pubjs = require('pubjs');
	var baseGrid = require('@base/grid').baseNoDate;
	var $ = require('jquery');
	var util = require('util');

	var Base = baseGrid.extend({
		init: function(config){
			config = $.extend({
				'is_sub_grid': false,
				'hasTab': false,
				'hasAmount': false,
				'hasExport': false,
				'sort': null
			}, config);
			this.Super('init', arguments);
		},
		getParam: function(){
			return this.config.customParam;
		},
		setParam: function(params, replace){
			this.config.customParam = replace ? params : util.merge(
				this.config.customParam,
				params
			);
		}
	});

	exports.base = Base;
	/**
	 * 登录信息
	 */
	var _renderLoginInfo = function(i,val,row,con){
		return [
			LANG("帐号添加时间：%1", util.date("Y-m-d H:i:s", row.CreateTime)),
			LANG("最近登录时间：%1", util.date("Y-m-d H:i:s", row.UpdateTime))
		].join('<br/>');
	};

	var _renderName = function(index,val,row){
		return '<p class="userName">'+val+'</p><p class="emailName">'+row.Name+'</p>';
	};


	var EmployeeList = Base.extend({
		init: function(config){
			config = pubjs.conf(config, {
				"cols":[
					{type:'id', width:50},
					{name:"UserName",text:LANG("员工姓名"),type:"index",render:_renderName},
					{name:"QQ",text:LANG("QQ号码"),align: 'center',render:'renderContact'},
					{name:"Phone",text:LANG("电话号码"),align: 'center',render:'renderContact'},
					{name:"Address",text:LANG("地址"),align: 'center',render:'renderContact'},
					{name:"Auth",text:LANG("权限"),align:"center",format:"formatAuth"},
					{name:"CreateTime",text:LANG("登录信息"),render:_renderLoginInfo}
				]
				,"is_sub_grid":false
				,"hasTab":false
				,"hasAmount":false
				,"hasExport":false
				//,"url":"/campany/listemployee"
				,"reqType": 'websocket'
				,"param": {}
			});

			//if (config.is_sub_grid){
			//	config.is_sub_grid = false;
			//	// config.hasSearch = true;
			//	config.param = $.extend(config.param, {
			//		'CampanyId': config.sub_id
			//	});
			//}
			this.gridType = 'employeeList';
			this.Super('init', arguments);
		},
		renderContact: function(index,val,row,con){
			if(!val){
				return '--'
			}
			return val;

		},
		formatAuth: function(val){
			switch(val){
				case 1:
					val = LANG("只读");
					break;
				case 2:
					val = LANG("可读写");
					break;
				case 3:
					val = LANG("管理员");
					break;
				default:
					val = LANG("未设置");
					break;
			}
			return val;
		},
		load: function(){
			// 员工列表作为子表格时，加载时传参
			var config = this.config;
			if(config.sub_id){
				config.param = $.extend(config.param, {
					'CampanyId': config.sub_id
				});
			}

			this.Super('load', arguments);
		}
	});

	exports.employeeList = EmployeeList;
});